﻿Imports System.Reflection

Public Module DataHelper
    'Public Function MapEntityFromDR(Of TEntityClass)(ByVal dr As DataRow) As TEntityClass
    '    Try
    '        Dim entityProperties = GetType(TEntityClass).GetProperties()
    '        Dim ent As TEntityClass = getInstance(Of TEntityClass)()

    '        Dim colNamesCollection As New Dictionary(Of String, String)
    '        For Each item As DataColumn In dr.Table.Columns
    '            colNamesCollection.Add(item.ColumnName, item.ColumnName.Replace(" "c, "_"))
    '        Next


    '        For Each p As PropertyInfo In entityProperties.Where(Function(x) x.CanWrite = True)
    '            Dim propertyName As String = p.Name

    '            Dim cNameList = colNamesCollection.Where(Function(x) x.Value.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase))
    '            If cNameList.Any() Then
    '                Dim colName = cNameList.FirstOrDefault().Key
    '                SetEntityValue(CObj(ent), p.Name, IIf(dr(colName) Is DBNull.Value, Nothing, dr(colName)))
    '            End If

    '        Next
    '        Return ent
    '    Catch ex As Exception
    '        Throw ex
    '    End Try
    'End Function

    Public Function getNotDBNull(ByVal value As Object) As Object
        If Not value Is Nothing AndAlso value Is DBNull.Value Then
            Return Nothing
        End If
        Return value
    End Function


End Module
